home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Offline / TestCamere / Test scena artificial / Data / common.js < prev    next >
Text File  |  2005-05-14  |  8KB  |  312 lines

  1. // Global constants
  2. var replacementChar = /%s/
  3. var timeoutID
  4. var playing
  5.  
  6. // Global variables
  7. var outputTitle
  8. var outputSubTitle
  9. var outputURL
  10. var imagesOnAPage
  11. var index
  12.  
  13. function parseCommandLine() {
  14.     if (location.href.indexOf("?") == -1) {
  15.         return 0
  16.     }
  17.  
  18.     // Parse any command line arguments
  19.     urlQuery = location.href.split("?")
  20.  
  21.     urlTerms = urlQuery[1].split(",")
  22.     if (urlTerms[0] != null) {
  23.         index = parseInt(urlTerms[0])
  24.     }
  25.  
  26.     if (urlTerms[1] != null) {
  27.         playing = parseInt(urlTerms[1])
  28.     }
  29. }
  30.  
  31. function printBodyStartTag() {
  32.     document.write("<BODY BGCOLOR=\"" + BGCOLOR + "\" TEXT=\"" + TEXT + "\" LINK=\"" + LINK + "\" VLINK=\"" + VLINK + "\" ALINK=\"" + ALINK + "\">")
  33.    document.write("<STYLE TYPE=\"text/css\">")
  34.    
  35.     document.write(".pageFont")
  36.     document.write("{")
  37.     document.write(pageFontFamily)
  38.     document.write(pageFontSize)
  39.     document.write("}")
  40.     
  41.    document.write(".thumbFont")
  42.     document.write("{")
  43.     document.write(thumbFontFamily)
  44.     document.write(thumbFontSize)
  45.     document.write(thumbFontColor)
  46.     document.write("}")
  47.     
  48.     document.write(".imageFont")
  49.     document.write("{")
  50.     document.write(imageFontFamily)
  51.     document.write(imageFontSize)
  52.     document.write(imageFontColor)
  53.     document.write("}")
  54.     
  55.     document.write("</STYLE>")
  56. }
  57.  
  58. function stopStartSlideShow(firstTime) {
  59.     if (playing == 1) {
  60.         playing = 0
  61.         clearTimeout(timeoutID)
  62.         
  63.         if (firstTime != 1)
  64.         {
  65.             index = -1
  66.             slideShow()
  67.         }
  68.     }
  69.     else {
  70.         playing = 1
  71.         timeoutID = setInterval("slideShow()", 3000)
  72.     }
  73. }
  74.  
  75. function slideShow() {
  76.     index = index + 1
  77.     if (index >= imageDB.length) {
  78.         index = 0
  79.     }
  80.  
  81.     // Change the image
  82.     window.location.href = "page.htm?" + index + "," + playing
  83.     
  84.  
  85.     // Change the play text to stop
  86.     slideShowControl.innerText="Stop";
  87. }
  88.  
  89. function init() {
  90.     // Make output strings from theme.js and data.js
  91.     outputTitle = themeTitle.replace(replacementChar, title);
  92.     outputSubTitle = themeSubTitle.replace(replacementChar, subTitle);
  93.     outputURL = themeURL.replace(replacementChar, URL);
  94.     outputURL = outputURL.replace(replacementChar, URL);
  95.  
  96.     // Perform some initial calculations
  97.     imagesOnAPage = rows*columns
  98.     
  99.     playing = 0
  100.     index = 0
  101.     parseCommandLine()
  102.  
  103.     // Start or stop the slideshow
  104.     if (playing == 0) {
  105.         playing = 1
  106.     }
  107.     else {
  108.         playing = 0
  109.     }
  110.     stopStartSlideShow(1)
  111. }
  112.  
  113. function printTitle(writePageTitle) {
  114.    if ((rows == 1 || columns == 1) && writePageTitle == 0) {
  115.       return
  116.    }
  117.     document.write("<DIV CLASS=\"title_div\">")
  118.     document.write("<SPAN CLASS=\"pageFont\">")
  119.     document.write(outputTitle)
  120.     document.write("</SPAN>")
  121.     document.write("</DIV>")
  122. }
  123.  
  124. function printSubTitle(writePageSubTitle) {
  125.    if ((rows == 1 || columns == 1) && writePageSubTitle == 0) {
  126.       return
  127.    }
  128.     document.write("<DIV CLASS=\"subtitle_div\">")
  129.     document.write("<SPAN CLASS=\"pageFont\">")
  130.     document.write(outputSubTitle)
  131.     document.write("</SPAN>")
  132.     document.write("</DIV>")
  133. }
  134.  
  135. function printImage() {
  136.     document.write("<DIV CLASS=\"image_div\">")
  137.     document.write("<TABLE>")
  138.     document.write("<TD>")
  139.     document.write("<TR valign=middle>")
  140.     document.write("<TD align=center>")
  141.     outputImageLink = themeImageLink.replace(replacementChar, index);
  142.     outputImageLink = outputImageLink.replace(replacementChar, playing);
  143.     document.write(outputImageLink)
  144.     document.write("</TD>")
  145.     document.write("</TR>")
  146.    for (var i = index*6; i < index*6+6; i++) {
  147.        document.write("<TR valign=middle>")
  148.        document.write("<TD CLASS=\"imageFont\" align=center>" + imageMetadataDB[i] + "</TD>")
  149.        document.write("</TR>")
  150.    }
  151.     document.write("</TD>")
  152.     document.write("</TABLE>");
  153.     document.write("</DIV>")
  154. }
  155.  
  156. function writeLinks(writePageLinks) {
  157.    if ((rows == 1 || columns == 1) && writeLinks == 1) {
  158.       return
  159.    }
  160.    
  161.     var themePreviousHolder = themeImageLinkPrevious
  162.     var themeNextHolder = themeImageLinkNext
  163.     var themePlayHolder = themeImageLinkPlay
  164.     var themeStopHolder = themeImageLinkStop
  165.     if (writePageLinks == 1)
  166.     {
  167.         themePreviousHolder = themeThumbLinkPrevious
  168.         themeNextHolder = themeThumbLinkNext
  169.         themePlayHolder = themeThumbLinkPlay
  170.         themeStopHolder = themeThumbLinkStop
  171.     }
  172.  
  173.     document.write("<DIV CLASS=\"links_div\">")
  174.  
  175.     document.write("<TABLE>")
  176.     document.write("<TR>")
  177.  
  178.     // Write previous link
  179.     document.write("<TD CLASS=\"pageFont\">")
  180.     document.write("<DIV CLASS=\"previous_div\">")
  181.     if (index != 0) {
  182.         var previousIndex
  183.         if (writePageLinks == 0) {
  184.             previousIndex = index - 1;
  185.             outputPreviousLink = themePreviousHolder.replace(replacementChar, previousIndex);
  186.             outputPreviousLink = outputPreviousLink.replace(replacementChar, playing);
  187.             document.write(outputPreviousLink)
  188.         }
  189.         else {
  190.             if (index != 0) {
  191.                 previousIndex = index-imagesOnAPage;
  192.                 if (previousIndex < 0) {
  193.                     previousIndex = 0              
  194.                 }
  195.                 outputPreviousLink = themePreviousHolder.replace(replacementChar, previousIndex);
  196.                 outputPreviousLink = outputPreviousLink.replace(replacementChar, playing);
  197.                 document.write(outputPreviousLink)
  198.             }
  199.         }
  200.     }
  201.     document.write("</DIV>")
  202.     document.write("</TD>")
  203.     
  204.     // Write URL
  205.     document.write("<TD CLASS=\"pageFont\">")
  206.     document.write("<DIV CLASS=\"url_div\">")
  207.     document.write(outputURL)
  208.     document.write("</DIV>")
  209.     document.write("</TD>")
  210.  
  211.     // Write next link
  212.     document.write("<TD CLASS=\"pageFont\">")
  213.     document.write("<DIV CLASS=\"next_div\">")
  214.     var nextIndex
  215.     if (writePageLinks == 0)
  216.     {
  217.         nextIndex = index + 1;
  218.         if (nextIndex < imageDB.length) {
  219.             outputNextLink = themeNextHolder.replace(replacementChar, nextIndex);
  220.             outputNextLink = outputNextLink.replace(replacementChar, playing);
  221.             document.write(outputNextLink)
  222.         }
  223.     }
  224.     else {
  225.         nextIndex = index+imagesOnAPage;
  226.         if (nextIndex < thumbDB.length) {
  227.             outputNextLink = themeNextHolder.replace(replacementChar, nextIndex);
  228.             outputNextLink = outputNextLink.replace(replacementChar, playing);
  229.             document.write(outputNextLink)
  230.         }
  231.     }
  232.     document.write("</DIV>")
  233.     document.write("</TD>")
  234.  
  235.     // Write play/stop
  236.     document.write("<TD CLASS=\"pageFont\">")
  237.     document.write("<DIV CLASS=\"slideShowControl_div\">")
  238.     if (playing == 1) {
  239.         document.write(themeStopHolder)
  240.     }
  241.     else {
  242.         document.write(themePlayHolder)
  243.     }
  244.     document.write("</DIV>")
  245.     document.write("</TD>")
  246.  
  247.     document.write("</TR>")
  248.     document.write("</TABLE>")
  249.  
  250.     document.write("</DIV>")
  251. }
  252.  
  253. function printTable() {
  254.     document.write("<DIV CLASS=\"images_div\">")
  255.     document.write("<TABLE>")
  256.     counter = index
  257.     for (var i = 0; i < rows; i++) {
  258.         document.write("<TR>")
  259.         for (var j = 0; j < columns; j++) {
  260.             if (counter < thumbDB.length) {
  261.                 document.write("<TD>")
  262.                 document.write("<TABLE>")
  263.                 document.write("<TD valign=top>")
  264.                 document.write("<TR>")
  265.                 document.write("<TD align=center>")
  266.                 outputThumbLink = themeThumbLink.replace(replacementChar, counter)
  267.                 outputThumbLink = outputThumbLink.replace(replacementChar, playing)
  268.                 document.write(outputThumbLink)
  269.                 document.write("</TD>")
  270.                 document.write("</TR>")
  271.                 
  272.                 // Write out the metadata
  273.                 for (var k = counter*6; k < counter*6+6; k++) {
  274.                    document.write("<TR valign=middle>")
  275.                    document.write("<TD CLASS=\"thumbFont\" align=center>" + thumbMetadataDB[k] + "</TD>")
  276.                    document.write("</TR>")
  277.                 }
  278.                 document.write("</TD>")
  279.                 
  280.                 document.write("</TABLE>");
  281.                 document.write("</TD>")
  282.             }
  283.  
  284.             counter++
  285.         }
  286.         document.write("</TR>")
  287.     }
  288.     document.write("</TABLE>")
  289.     document.write("</DIV>")
  290. }
  291.  
  292. function loadImages() {
  293.     for (var i = 0; i < imagesOnAPage; i++) {
  294.         if ((i+index) < thumbDB.length) {
  295.             var j = 0
  296.             while (document.images[j] != null && document.images[j].name == "IGNORE") {
  297.                 j++
  298.             }
  299.             if (document.images[i+j] != null) {
  300.                 document.images[i+j].src = thumbDB[i+index]
  301.             }
  302.         }
  303.     }
  304. }
  305.  
  306. function loadImage() {
  307.    var i = 0
  308.    while (document.images[i].name == "IGNORE") {
  309.       i++
  310.    }
  311.     document.images[i].src = imageDB[index]
  312. }